﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using FluentValidation;
using CashFlow.ShopManage.Models.User;
using CashFlow.ShopManage.Common;

namespace CashFlow.ShopManage.Validator.User
{
    public class UpdateUserModelValidator
        : AbstractValidator<UpdateUserModel>
    {
        public UpdateUserModelValidator()
        {
            CascadeMode = CascadeMode.Stop;
            RuleFor(x => x.UserId).Must(x => ValidatorTool.IsUserBelongsMyShop(x))
                .WithMessage("非法UserId");
            RuleFor(x => x.Phone).Must(x => RegExpTool.IsPhone(x))
                .WithMessage("手机号码格式不正确！");
            RuleFor(x => x.Name).Must(x => RegExpTool.IsName(x))
                .WithMessage("姓名格式不正确！");
        }
    }
}